package com.heima.user.controller.v1;

import com.heima.common.user.UserConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dto.AuthDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.heima.user.service.ApUserRealnameService;

/**
 * @author huan
 * @serial 每天一百行, 致敬未来的自己
 * @Description
 */
@RestController
@RequestMapping("/api/v1/auth")
@Api(value = "APP用户管理", tags = "APP用户管理")
public class ApUserRealnameController {
    @Autowired
    private ApUserRealnameService apUserRealnameService;


    @PostMapping("/list")
    @ApiOperation("根据状态查询用户认证列表")
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.loadListByStatus(dto);
    }

    @PostMapping("/authPass")
    @ApiOperation("app端用户认证后审核通过")
    public ResponseResult ApUserAuthPass(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto, UserConstants.PASS_AUTH);
    }

    @PostMapping("/authFail")
    @ApiOperation("app端用户认证后审核失败")
    public ResponseResult ApUserAuthFail(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto, UserConstants.FAIL_AUTH);
    }
}
